//
//  MyDateformater.m
//  coba-iOS
//
//  Created by 郭四虎 on 15/12/5.
//  Copyright © 2015年 YouKu. All rights reserved.
//

#import "MyDateformater.h"

@implementation MyDateformater

+ (NSString *)formater:(NSString *)date
{
    NSDateFormatter *formater = [[NSDateFormatter alloc]init];
    [formater setDateFormat:@"yyyy-MM-dd HH:mm:ss.s"];
    NSDate *dat = [formater dateFromString:date];
    [formater setDateFormat:@"yy-MM-dd HH:mm"];
    NSString *datestr = [formater stringFromDate:dat];
    return datestr;
}

+ (NSString *)formaterYMH:(NSString *)date
{
    NSDateFormatter *formater = [[NSDateFormatter alloc]init];
    [formater setDateFormat:@"yyyy-MM-dd HH:mm:ss.s"];
    NSDate *dat = [formater dateFromString:date];
    [formater setDateFormat:@"yyyy-MM-dd"];
    NSString *datestr = [formater stringFromDate:dat];
    return datestr;
}

+ (NSString *)getCurrentDate
{
    NSDateFormatter *formater = [[NSDateFormatter alloc]init];
    [formater setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *date = [formater stringFromDate:[NSDate date]];

    return date;
}



+ (NSString *)getDateString:(NSDate *)date
{
    NSDateFormatter *formater = [[NSDateFormatter alloc]init];
    [formater setDateFormat:@"yyyy-MM-dd"];
    NSString *dateStr = [formater stringFromDate:date];
    
    return dateStr;
}

@end
